package com.devframe.maven.plugin;

/*
 * Copyright 2001-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.apache.commons.lang.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;


/**
 *
 * @goal fileDel
 * @phase package
 * @requiresProject
 * @threadSafe
 * @requiresDependencyResolution runtime
 */
public class FileDelMojo extends AbstractMojo
{
	
   
    /**
     * The Maven project.
     *
     * @parameter default-value="${project}"
     * @required
     * @readonly
     */
    private MavenProject myProject;
    
    /**
     * 删除指定的文件夹
     * 如：src/main/resources/pages
     * @parameter
     * @required
     */
    private String targetDir;
    
    
 
	
	public void execute() throws MojoExecutionException {
		if(StringUtils.isEmpty(targetDir)){
			throw new MojoExecutionException("delDir为空，需指定要删除的文件夹路径");
		}
		super.getLog().info("delDir="+targetDir);
		String toDir=myProject.getBasedir().getPath()+"/"+this.targetDir;
		FileDelUtil.delFolder(toDir);
	}

}
